﻿using System;
using Zeus.Thunder.Core;

namespace SharpTrainer.Delegates
{
  delegate double DoubleOp(double x);
  
  class SimpleDelegate : ITestCase
  {
    public void Run()
    {
      DoubleOp[] operations = 
            {
              new DoubleOp(MathsOperations.MultiplyByTwo),
              new DoubleOp(MathsOperations.Square)
            };

      for (int i = 0; i < operations.Length; i++)
      {
        Console.WriteLine("Using operations[{0}]:", i);
        ProcessAndDisplayNumber(operations[i], 1.5);
        ProcessAndDisplayNumber(operations[i], 2);
        ProcessAndDisplayNumber(operations[i], 8.6);
        Console.WriteLine();
      }

      Console.ReadLine();
    }

    static void ProcessAndDisplayNumber(DoubleOp action, double value)
    {
      double result = action(value);
      Console.WriteLine("Value is {0}, result of operation is {1}", value, result);
    }
  }
}
